#pragma once

#include <cstdint>

struct ID3D10Device;
struct ID3D10Buffer;

namespace DirectX
{
    struct XMFLOAT3;
}

namespace D3D10Utils
{
	struct Vertex;

	class Waves
	{
	public:
		Waves(const uint32_t rows, const uint32_t columns);
		~Waves();

		void init(ID3D10Device * const device, const float cellSpacing, const float deltaTime, 
			const float speed, const float damping);

		void update(const float deltaTime);
		void disturb(const uint32_t iRow, const uint32_t jColumn, const float magnitude);
		void draw();		

	private:
		Vertex* createVertices();
		uint32_t* createIndices();
		void initVertexBuffer();
		void initIndexBuffer();

		ID3D10Device *mDevice;
		ID3D10Buffer *mVertexBuffer;
		ID3D10Buffer *mIndexBuffer;

		const uint32_t mNumVertices;
		const uint32_t mNumFaces;

		const uint32_t mRows;
		const uint32_t mColumns;

        DirectX::XMFLOAT3* mPreviousSolution;
		DirectX::XMFLOAT3* mCurrentSolution;
		DirectX::XMFLOAT3* mNormals;

		float mK1;
		float mK2;
		float mK3;
		float mTimeStep;

		float mSpatialStep;
	};
}
